<!DOCTYPE html>
<html class="x-admin-sm" lang="en" xmlns:th="https://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>
        人岗匹配日志配置
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" th:href="@{/assets/admin/css/font.css}">
    <link rel="stylesheet" th:href="@{/assets/admin/css/xadmin.css}">
    <script th:src="@{/assets/admin/lib/layui/layui.js}" charset="utf-8"></script>
    <script type="text/javascript" th:src="@{/assets/admin/js/xadmin.js}"></script>
    <script type="text/javascript" th:src="@{/assets/plugins/wangEdit/wangEditor.min.js}"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<style type="text/css">
    .layui-form-label{
        width: 105px;
        font-size:14px;
        font-weight: 700;
    }
    .layui-form-item{
        margin-bottom:5px;
    }
    .layui-table-cell .layui-form-checkbox[lay-skin="primary"] {
        top: 3px;
    }
    .xm-select-demo .xm-body{
        z-index : 999999;
    }
    .xm-label-block {
        overflow:hidden;
    }
    xm-select > .xm-label .xm-label-block{
        display: inline-flex;
    }
    #deliveryBusName .label-content{
        max-height: 38px;
        overflow: hidden;
    }
</style>
<body>
<div class="layui-fluid" style="padding-bottom: 0px;width:650px;margin:0 auto;">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5" lay-filter="query_it_form" id="tf_query_form">
                        <input type="hidden" name="key" id="key"
                               th:value="${entity == null ? '' : entity.key}">
                        <input type="hidden" name="id" id="id"
                               th:value="${entity == null ? '' : entity.id}">
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-form-item">
                                <label class="layui-form-label">邮件主题</label>
                                <div class="layui-input-inline" style="width: 470px;">
                                    <input type="text" style="width:470px;height: 38px;" class="layui-input" name="title"
                                           placeholder="请输入邮件主题" th:value="${entity == null ? '': entity.title}" />
                                </div>
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-form-item">
                                <label class="layui-form-label">邮件内容</label>
                                <div class="layui-input-inline" style="width: 470px;"
                                     id="content">
                                    [(${entity == null ? '' :entity.content})]
                                </div>
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-form-item">
                                <label class="layui-form-label">邮件默认接收人</label>
                                <div class="layui-input-inline" style="width: 470px;">
                                    <div class="fairy-tag-container" >
                                        <input id="input-tag1" type="text" class="fairy-tag-input tag1" autocomplete="off" value="">
                                    </div>
                                    <input id="defualtRecipiener" name="defualtRecipiener"
                                           th:value="${entity == null?'': entity.defualtRecipiener }"
                                           type="hidden"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <div class="layui-form-item">
                                <label class="layui-form-label">异常邮件通知人</label>
                                <div class="layui-input-inline" style="width: 470px;">
                                    <div class="fairy-tag-container" >
                                        <input id="input-tag2" type="text" class="fairy-tag-input tag1" autocomplete="off" value="">
                                    </div>
                                    <input id="abnormalRecipiener" name="abnormalRecipiener"
                                           th:value="${entity == null ? '' :entity.abnormalRecipiener}"
                                           type="hidden"/>
                                </div>
                            </div>
                        </div>
                    </form>
                    <br/>
                    <div class="layui-btn-container" style="width:100%;text-align: center">
                        <button type="button" class="layui-btn layui-btn-normal" lay-submit lay-filter="save">
                            <i class="layui-icon">&#x1005;</i>保存
                        </button>
                    </div>
                    <hr style="margin-top:5px;margin-bottom: 5px"/>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script th:src="@{/assets/admin/js/jquery.min.js}"></script>
<script th:replace="systemCommon/HarinCommon :: commonJs"></script>
<script>
    let editor;
    $(function(){
        //初始化富文本
        const E = window.wangEditor
        editor = new E('#content')
        // 或者 const editor = new E( document.getElementById('div1') )
        //editor.highlight = hljs;
        editor.config.menus = [
            'head',
            'bold',
            'fontSize',
            'fontName',
            'italic',
            'underline',
            'strikeThrough',
            'indent',
            'lineHeight',
            'foreColor',
            'backColor',
            'list',
            'justify',
            'quote',
            'table',
            'code',
            'splitLine',
            'undo',
            'redo',
        ]
        // 菜单栏提示为上标（默认配置）
        editor.config.menuTooltipPosition = 'up'
        editor.config.pasteFilterStyle = false; //关闭样式过滤
        editor.config.pasteIgnoreImg = true;
        editor.config.height = 200; //设置高度
        editor.config.weight = 400; //设置高度
        editor.create();
        $("#as").on('click',function(){
            console.log(editor.txt.html());
        });

    });

    layui.config({
        base: '/assets/admin/lib/layui/mods/'
    }).extend({
        inputTag : "inputTag"
    });

    layui.use(['inputTag','jquery','form','layer','table'], function () {
        form = layui.form;
        $ = layui.jquery;
        layer = layui.layer;
        table = layui.table;
        inputTag  = layui.inputTag;

        colsTable = null;

        defualtRecipiener = inputTag.render({
            elem: `#input-tag1`,
            data:  strJson2Array($("#defualtRecipiener").val()),
            onChange: function (data, value, type) {
                // newObj.resultArray = data;
                // $(`#tag-result-${newObj.id}`).text(data.join(''));
                // $(`${newObj.exportElem}`).val(data.join(''));
                // $(`${newObj.exportDataToStrElem}`).val(data.join(','));
            }

        });

        abnormalRecipiener = inputTag.render({
            elem: `#input-tag2`,
            data:  strJson2Array($("#abnormalRecipiener").val()),
            onChange: function (data, value, type) {
                // newObj.resultArray = data;
                // $(`#tag-result-${newObj.id}`).text(data.join(''));
                // $(`${newObj.exportElem}`).val(data.join(''));
                // $(`${newObj.exportDataToStrElem}`).val(data.join(','));
            }

        });




        /**
         * 点击保存
         */
        form.on('submit(save)', function (data) {
            console.log(data);
            let saveObj  = form.val("query_it_form");
            saveObj["defualtRecipiener"] = defualtRecipiener.copyData;
            saveObj["abnormalRecipiener"] = abnormalRecipiener.copyData;

            saveObj["content"] = editor.txt.html();

            $.ajax({
                url:"/busnissSetting/saveMailSetting",
                type:"post",
                contentType: 'application/json',
                data: JSON.stringify(saveObj),
                success:function(data){
                    if(data.code == 200) {
                        layer.alert(data.message, {icon: 6}, function (iIndex) {
                            layer.close(iIndex);
                        });
                    }else{
                        layer.alert(data.message, {icon: 5}, function (iIndex) {
                            layer.close(iIndex);
                        });
                    }
                }
            })
            return false;
        });
        //点击行checkbox选中  layui的table单击高亮显示
        $(document).on("click", ".layui-table-body table.layui-table tbody tr", function() {
            var index = $(this).attr('data-index');
            var tableBox = $(this).parents('.layui-table-box');
            //存在固定列
            if (tableBox.find(".layui-table-fixed.layui-table-fixed-l").length > 0) {
                tableDiv = tableBox.find(".layui-table-fixed.layui-table-fixed-l");
            } else {
                tableDiv = tableBox.find(".layui-table-body.layui-table-main");
            }
            var checkCell = tableDiv.find("tr[data-index=" + index + "]").find("td div.laytable-cell-checkbox div.layui-form-checkbox I");
            if (checkCell.length > 0) {
                checkCell.click();
            }
        });

        $(document).on("click", "td div.laytable-cell-checkbox div.layui-form-checkbox", function(e) {
            e.stopPropagation();
        });

    });
    function strJson2Array(str){
        if(str == null || str == undefined || str ==''){
            return [];
        }
        return JSON.parse(str);
    }
</script>
</html>